package com.syb.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.syb.dao.UserDao;
import com.syb.entity.user.SysUser;
import com.syb.service.UserService;
import com.syb.util.PageResults;

@Service
public class UserServiceImpl implements UserService {
	
	@Autowired
	private UserDao userDao;

	@Override
	public PageResults<SysUser> getUserList(PageResults<SysUser> page)throws Exception {
		List<SysUser> userList = new ArrayList<SysUser>();
		PageResults<SysUser>  pageList = new PageResults<SysUser>();
		int count = 0;
		try{
			userList = userDao.findUserList(page);
		}catch(Exception e){
			throw new Exception(e.getMessage());
		}
		try{
			count = userDao.findUsercount(page);
		}catch(Exception e){
			throw new Exception(e.getMessage());
		}
		pageList.setTotalCount(count);
		pageList.setPageNo((page.getCurrentPage()/page.getPageSize())+1);
		pageList.setResults(userList);
		
		return pageList;
	}

}
